<template>
  <div class="divBox">
    <el-card class="box-card">
      <el-form inline size="small" @submit.native.prevent>
        <el-form-item label="关键词：">
          <el-input v-model="listPram.name" placeholder="请输入姓名" clearable class="selWidth"/>
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-search" size="mini" type="primary" @click="handleSearch">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
        <el-button icon="el-icon-upload2" size="mini" type="primary" @click="openEdit()" style="margin-left:0;"
        >福利费导入
        </el-button>
      </el-form>
      <el-table :data="listData.list" v-loading="loading" size="mini"
                :header-cell-style=" {fontWeight:'bold',background:'#f8f8f9',color: '#515a6e',height:'40px'}" border
      >
        <el-table-column
          prop="serialNumber"
          label="序号"
          width="50"
        />
        <el-table-column label="姓名" prop="name" min-width="120"/>
        <el-table-column label="性别" prop="gender" min-width="120"/>
        <el-table-column label="军衔等级" prop="rankTitle" min-width="120">
        </el-table-column>
        <el-table-column label="公民身份证号" prop="idcard" min-width="120"/>
        <el-table-column label="部职别" prop="positionDesc" min-width="120"/>
        <el-table-column label="实际工作岗位" prop="actualJob" min-width="120"/>
        <el-table-column label="操作" min-width="130" fixed="right">
          <template slot-scope="scope">
            <el-button icon="el-icon-edit" type="primary" size="mini" @click="handlerOpenEdit(1,scope.row)"
                       v-hasPermi="['admin:enjoy:info']"
            >管理
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="listPram.page"
        :page-sizes="constants.page.limit"
        :layout="constants.page.layout"
        :total="listData.count"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </el-card>
    <el-dialog
      :visible.sync="editDialogConfig.visible"
      :title="'福利管理'"
      destroy-on-close
      :close-on-click-modal="false"
      width="1500px"
    >
      <info
        v-if="editDialogConfig.visible"
        :is-create="editDialogConfig.isCreate"
        :edit-data="editDialogConfig.editData"
        @hideEditDialog="hideEditDialog"
      />
    </el-dialog>
    <el-dialog
      :visible.sync="editDialog.show"
      :title="'导入'"
      destroy-on-close
      :close-on-click-modal="false"
      width="1200px"
    >
      <edit
        v-if="editDialog.show"
        @handlerOpenEdit1="handlerOpenEdit1"
      />
    </el-dialog>
  </div>
</template>

<script>
import { list } from '@/api/enjoy'
import info from './info'
import Edit from '@/views/enjoy/edit.vue'

export default {
  components: { Edit, info },
  data() {
    return {
      constants: this.$constants,
      loading: false,
      listData: { list: [] },
      listPram: {
        name: '',
        page: 1,
        limit: this.$constants.page.limit[0]
      },
      editDialogConfig: {
        visible: false,
        isCreate: 0, // 0=创建，1=编辑
        editData: {}
      },
      editDialog:{
        show:false
      },
    }
  },
  mounted() {
    this.handleGetList()
  },
  methods: {
    openEdit(){
      this.editDialog.show=true
    },
    handlerOpenEdit1(){
      this.editDialog.show=false
      this.handleGetList()
    },
    handleSearch() {
      this.listPram.page = 1
      this.handleGetList()
    },
    handleSizeChange(val) {
      this.listPram.limit = val
      this.handleGetList()
    },
    handleCurrentChange(val) {
      this.listPram.page = val
      this.handleGetList()
    },
    handleGetList() {
      list(this.listPram).then(data => {
        this.listData = data
      })
    },
    handlerOpenEdit(isCreate, editDate) {
      this.editDialogConfig.editData = editDate
      this.editDialogConfig.isCreate = isCreate
      this.editDialogConfig.visible = true
    },
    hideEditDialog() {
      this.editDialogConfig.visible = false
      this.handleGetList()
    },
    resetQuery() {
      this.listPram.name = ''
      this.handleGetList()
    },
  }
}
</script>

<style scoped>

</style>
